import { IRouteComponentProps } from "umi";
import { Layout} from 'antd';
import HeaderBase from './header';
import "./index.css"
import SiderBase from './sider';
import { useState} from 'react';
export default function({children,location}:IRouteComponentProps){
     // 声明控制侧边菜单展开和收起的数据
  const [collapsed, setCollapsed] = useState(false);
  // 控制菜单栏展开收起
  let changeCollapse =()=>{
    setCollapsed(!collapsed)
  }
     //console.log(location);
    //  不需要布局
   if(location.pathname==="/login"){
        return children
   }else{//需要布局
        return(
                <Layout>
                     <SiderBase collapsed={collapsed}/>
                    <Layout className="site-layout">
                    <HeaderBase collapsed={collapsed} changeCollapse={changeCollapse}/>
                        {children}
                    </Layout>
                </Layout>
        )
   }
}